<!doctype html>
<html class="no-js">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>广东穗智律师事务所</title>
    <meta name="description" content="在线咨询">
    <meta name="keywords" content="穗智 在线咨询">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="images/logo.ico">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="http://cdn.amazeui.org/amazeui/2.7.2/css/amazeui.min.css"/>
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="stylesheet" href="assets/css/suit.css">
</head>
<style>
    body {
        font-size: 13px;
    }

    .nav {
        font-size: 20px;
    }

    .am-topbar-nav > li > a {
        color: #000;
        line-height: 1.6;
        padding: 5px 10px;
    }

    .border-line > li {
        border-left: 1px solid #000;

    }

    .am-nav-pills > li + li {
        margin: 0;
    }

    .border-line {
        border-right: 1px solid #000;
    }

    header div img:hover {
        background-color: #EFEDEF;
    }

    .nav-justify > li {
        float: none;
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
    }

    .nav-justify > li > a {
        text-align: center;
        margin-bottom: 0;
    }

    .nav-justify {
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
    }
</style>
<body>
<header class="am-topbar am-text-center am-show-sm-only" style="margin-bottom:0">

    <div class="am-u-lg-5 am-u-md-4 am-u-sm-8 am-text-center am-u-md-push-1">
        <a href="index.html"><img src="images/logo-sz.png" style="max-height: 60px;"></a>
    </div>
    <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only"
            data-am-collapse="{target: '#doc-collapse'}"><span class="am-sr-only">导航切换</span> <span
            class="am-icon-bars"></span>
    </button>

    <div class="am-show-sm-only">
        <div class="am-collapse am-topbar-collapse" id="doc-collapse" style="padding:0 10%">
            <ul class="am-nav am-nav-pills am-topbar-nav nav">
                <li><a href="profile.html">律所概况</a></li>
                <li><a href="case.html">成功案例</a></li>
                <li><a href="team.html">穗智团队</a></li>
                <li class="am-active"><a href="message.html">在线咨询</a></li>
                <li><a href="contact.html">联系我们</a></li>
            </ul>
        </div>
    </div>

    <div style="font-size: 10px;padding: 10px 9%;"
         class="am-text-left am-u-lg-5 am-u-md-4 am-u-sm-4 am-u-md-push-1 am-hide-sm-only">
        <div>
            地址：广州市海珠区广州大道南448号财智大厦901室
        </div>
        <div>
            电话：<a href="tel:020-28022100">020-28022100</a>
        </div>
    </div>
</header>

<!--<div class="am-padding-0 am-margin-top-sm">-->
<div class="am-padding-0">
    <img src="images/other.jpg" class="am-u-sm-12 am-u-md-12 am-padding-0">
</div>
<div class="am-u-md-12">
    <br>
</div>
<div class="am-collapse am-topbar-collapse" id="doc-topbar-collapse" style="padding:0 10%">
    <ul class="am-nav am-nav-pills am-topbar-nav nav am-u-md-8 am-u-md-push-2 am-u-md-pull-2 nav-justify border-line">
        <li><a href="index.html">首页<br>
            <div style="font-size: 8px;margin: 0;padding: 0">Home</div>
        </a></li>
        <li><a href="profile.html">律所概况<br>
            <div style="font-size: 8px;margin: 0;padding: 0">About Us</div>
        </a></li>
        <li><a href="case.html">成功案例<br>
            <div style="font-size: 8px;margin: 0;padding: 0">Successful Case</div>
        </a></li>
        <li><a href="team.html">穗智团队<br>
            <div style="font-size: 8px;margin: 0;padding: 0">Team Introduce</div>
        </a></li>
        <li><a href="message.html">在线咨询<br>
            <div style="font-size: 8px;margin: 0;padding: 0">Consultation</div>
        </a></li>
        <li><a href="contact.html">联系我们<br>
            <div style="font-size: 8px;margin: 0;padding: 0">Contact Us</div>
        </a></li>
    </ul>
</div>

<!-- content start -->
<div class="am-u-sm-12">
    <div class="admin-content ">
        <div class="am-u-md-push-3 am-u-md-push-1 am-u-md-6">
            <br>
            <br>
            <strong class="am-text-default am-text-xl">在线留言</strong>
            <hr data-am-widget="divider" style="" class="am-divider am-divider-default"/>
        </div>

        <!--留言表单-->
        <form class="am-form am-form-horizontal " id="messages">
            <div class="am-form-group am-u-md-12">
                <label class="am-u-sm-4 am-u-md-2 am-form-label am-u-md-push-2">联系电话</label>
                <div class="am-u-sm-8 am-u-md-4 am-u-md-pull-4">
                    <input type="text" id="tel" name="phone" placeholder="请输入您的手机号码">
                </div>
            </div>

            <div class="am-form-group am-u-md-12">
                <label class="am-u-sm-4 am-u-md-2 am-form-label am-u-md-push-2">留言内容</label>
                <div class="am-u-sm-8 am-u-md-4 am-u-md-pull-4">
                    <textarea type="text" id="content" name="qusetion" rows="4" placeholder="请输入您的留言..."></textarea>
                </div>
            </div>

            <div class="am-text-center am-u-md-12">

                <button type="reset" class="am-btn am-btn-warning am-btn-xs">重置</button>
                <button type="button" class="am-btn am-btn-primary am-btn-xs" id="save-form">提交
                </button>
            </div>

        </form>
    </div>
</div>
<br><br>
<div class="am-u-md-push-3 am-u-md-push-1 am-u-md-6">
    <strong class="am-text-default am-text-xl">留言板</strong>
    <hr data-am-widget="divider" style="" class="am-divider am-divider-default"/>
</div>

<!--留言模块--> <!--以下注释不能删！！！！-->
<div class="am-u-lg-10 am-u-lg-push-1 am-u-lg-pull-1">
    <div id="waterfall" style="text-align: center;" class="am-u-md-12">
        <!-- <div class="cell" >
             <article class="comment">
                 <div class="comment-main">
                     <header class="comment-hd">
                         <div class="comment-meta"><a class="comment-author">${phone}</a> 留言于
                             <time >${createtime}</time>
                         </div>
                     </header>
                     <div class="comment-bd"><p>
                         <strong>${qusetion}</strong></p>
                         ${answer}
                     </div>
                 </div><br/>
             </article>
         </div>-->
    </div>
</div>
<div class="am-u-md-12">
    <hr data-am-widget="divider" style="" class="am-divider am-divider-default"/>
    <div class="am-text-center am-u-md-12" id="tip">
        数据加载中<i class="am-icon-spinner am-icon-pulse"></i>
    </div>
    <br>
    <hr data-am-widget="divider" style="" class="am-divider am-divider-default"/>
</div>

<footer data-am-widget="footer"
        class="am-footer am-footer-default am-u-sm-12"
        data-am-footer="{  }" style="position:relative;bottom: 0">
    <hr>
    <div style="font-size: 10px;">
        <div>
            地址：广州市海珠区广州大道南448号财智大厦901室
        </div>
        <div>
            电话：<a href="tel:020-28022100">020-28022100</a>
        </div>
    </div>
    <div class="am-footer-miscs ">
        <p>CopyRight©2016 suizhilaw</p>
        <p>粤ICP备16096850号</p>
    </div>
</footer>
<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>

<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="assets/js/waterfall.js"></script>
<script src="assets/js/jquery.form.min.js"></script>

<!--<![endif]-->
<script src="http://cdn.amazeui.org/amazeui/2.7.2/js/amazeui.min.js"></script>
<script src="assets/js/app.js"></script>
<script>

    $("#save-form").on("click", function () {
        var reg = /^[1-9]\d{10}$/;
        if (!reg.test($("#tel").val())) {
            alert("请填写正确的手机号码！")
            return;
        }
        if ($("#content").val().trim() == "") {
            alert("请填写留言")
            return;
        }
        $("#messages").ajaxSubmit({
            type: 'post',
            url: 'view/addContact.action',
            success: function (data) {
                console.log(data);
                alert("提交成功！");
                location.reload();
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                console.log(XmlHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
                alert("提交失败！");
            }
        });
    });

    var content = $("#waterfall").html().trim().substring(4).replace("-->", "");

    //ajax封装
    function ajax(url, data, success, error, type_) {
        if (type_ == "") type_ = 'post';
        $.ajax({
            type: type_,
            data: data,
            url: url,
            dataType: 'json',
            contentType: "application/json",
            success: function (d) {
                success(d);
            },
            error: function (e) {
                error(e);
            }
        });
    }

    /*ajax成功填充页面*/
    function appenMessage(data) {
        var messages = data.messages;
        $("#waterfall").html("");
        for (var i = 0; i < messages.length; i++) {
            $("#waterfall").append(appenContent(content, messages[i]));
        }
        var pages = data.pages;
        var width = ($(window).width() > 1000) ? $(window).width() * 0.2 : ($(window).width() > 500) ? $(window).width() * 0.4 : $(window).width() * 0.8;

        console.info(width);
        var opt = {
            getResource: function (index, render) {//index为已加载次数,render为渲染接口函数,接受一个dom集合或jquery对象作为参数。通过ajax等异步方法得到的数据可以传入该接口进行渲染，如 render(elem)
                if (index < pages) {
                    var html = "";
                    ajax("view/getContacts.action?pageNo=" + (parseInt(index) + parseInt(1)), "", function (data) {
                        var messages = data.messages;
                        for (var i = 0; i < messages.length; i++) {
                            html += appenContent(content, messages[i]);
                        }
                        render($(html));
                    }, error, "get");
                } else {
                    $("#tip").html("留言加载完毕！")
                }
            },
            column_width: width,//列宽
            auto_imgHeight: true,
            insert_type: 1
        }
        $('#waterfall').waterfall(opt);
    }

    function appenContent(content, data) {
        for (var key in data) {
            if (key == "createtime") {
                data[key] = new Date(data[key]);
                data[key] = data[key].getFullYear() + "-" + (data[key].getMonth() + 1) + "-" + data[key].getDate() + " " + data[key].getHours() + ":" + data[key].getMinutes();
            } else if (key == "answer") {
                data[key] = (data[key] != null) ? "<blockquote>已回复：" + data[key] + "</blockquote>" : "";
            }
            content = content.replace("${" + key + "}", (data[key] == null) ? "" : data[key]);
        }
        return content;
    }

    function error(e) {
        console.error(e);
        alert("网页遇到了点错误，不如刷新试试☺");
    }

    ajax("view/getContacts.action?pageNo=1", "", appenMessage, error, "get");

</script>
</body>
</html>
